<include file="Public/min-header"/>
<link href="__PUBLIC__/plugins/daterangepicker/daterangepicker-bs3.css" rel="stylesheet" type="text/css" />
<script src="__PUBLIC__/plugins/daterangepicker/moment.min.js" type="text/javascript"></script>
<script src="__PUBLIC__/plugins/daterangepicker/daterangepicker.js" type="text/javascript"></script>
<div class="wrapper">
  <include file="Public/breadcrumb"/>
  <style type="text/css">
  	.table input{display: nones;}
	#biaozhu{cursor: pointer;}
	#yc{color:red; display: nones;}
  </style>
   <script type="text/javascript">
   jQuery.fn.rowspan = function(colIdx) { //封装的一个JQuery小插件  
   return this.each(function(){ 
   var that; 
   $('tr', this).each(function(row) { 
   $('td:eq('+colIdx+')', this).filter(':visible').each(function(col) { 
   if (that!=null && $(this).html() == $(that).html()) { 
   rowspan = $(that).attr("rowSpan"); 
   if (rowspan == undefined) { 
   $(that).attr("rowSpan",1); 
   rowspan = $(that).attr("rowSpan"); } 
   rowspan = Number(rowspan)+1; 
   $(that).attr("rowSpan",rowspan); 
   $(this).hide(); 
   } else { 
   that = this; 
   } 
   }); 
   }); 
   }); 
   }
   
   $(function() {
   	$(".g_list").rowspan(2);
 //   	$(".g_list").rowspan(4);
	$(".g_list").rowspan(4);
	// $(".g_list").rowspan(6);
	// $(".g_list").rowspan(7);
   }); 
   
   </script>
  <section class="content">
    <div class="container-fluid">
      <div class="panel panel-default"> 
        <div class="panel-heading"> 
          <h3 class="panel-title"><i class="fa fa-list"></i>异常订单</h3>
        </div>
        <div class="panel-body">    
		<div class="navbar navbar-default">
                <form id="search-form2" class="navbar-form form-inline"  method="get" action="{:U('unusual')}">
                <div class="form-group">
					<?php
								if(session('fenbu_id')==0){
								?>
					<div class="form-group">
						<select name="fenbu_id" id="fenbu_id" class="input-sm" style="width:100px;">
							<option value="" >全部</option>
							<?php
									 foreach($fenbu_list as $v){
										if(I('fenbu_id')==$v['fenbu_id']){
											 echo '<option value="'.$v['fenbu_id'].'" selected="selected">'.$v['fenbu_name'].'</option>';
							}else{
							echo '<option value="'.$v['fenbu_id'].'">'.$v['fenbu_name'].'</option>';
							}
							}
							?>
						</select>
					</div>
					<?php
								}else{
									echo '<input type="hidden" name="fenbu_id" id="fenbu_id" value="'.session('fenbu_id').'" />';
					}
					?>


					<div class="input-group">
                    <input type="text" class="form-control" id="order_sn" placeholder="订单号" value="{$Think.request.order_sn}" name="order_sn" />
                  </div>

                  <div class="input-group">
                    <input type="text" class="form-control" id="shanghu" placeholder="商户名" value="{$Think.request.shanghu}" name="shanghu" style="width: 100px;"/>
                  </div>
				  <div class="input-group">
				    <input type="text" class="form-control" id="kehu" placeholder="客户名" value="{$Think.request.kehu}" name="kehu" style="width: 100px;"/>
				  </div>

					<div class="form-group">
						<div class="input-group">
							<input type="text" name="biaoshi_xian" id="biaoshi_xian" placeholder="路线"  class="form-control" value="{:I('biaoshi_xian')}" style="width:100px;">
						</div>
					</div>
				


					<div class="form-group">
						<select name="tag" id="tag" class="form-control">
							<?php
							if(I('tag')=='1'){
								echo '<option value="">是否回款</option>
							<option value="1" selected="selected">未回款</option>
							<option value="2">已回款</option>';
							}elseif(I('tag')=='2'){
							echo '<option value="">是否回款</option>
							<option value="1">未回款</option>
							<option value="2" selected="selected">已回款</option>';
							}else{
							echo '<option value="" selected="selected">是否回款</option>
							<option value="1">未回款</option>
							<option value="2">已回款</option>';
							}
							?>
						</select>
					</div>


					<div class="form-group">
						<select name="unusual_type" id="unusual_type" class="form-control">
							<?php
							if(I('unusual_type')=='1'){
								echo '<option value="">异常状态</option>
							<option value="1" selected="selected">入库不齐</option>
							<option value="2">没货</option>';
							}elseif(I('unusual_type')=='2'){
							echo '<option value="">入库不齐</option>
							<option value="1">未回款</option>
							<option value="2" selected="selected">没货</option>';
							}else{
							echo '<option value="" selected="selected">异常状态</option>
							<option value="1">入库不齐</option>
							<option value="2">没货</option>';
							}
							?>
						</select>
					</div>

					<div class="form-group">
						<div class="input-group">
							<input type="text" name="timegap" value="{$timegap}" placeholder="下单日期"  id="add_time" class="input-sm" style="width: 220px;">
						</div>
					</div>

                </div>
                <div class="form-group">
                    <button class="btn btn-primary" id="button-filter search-order" type="submit"><i class="fa fa-search"></i> 筛选</button>
                </div>


					<div class="form-group">
						<button type="button" class="btn btn-default pull-right" id="daochu"><i class="fa fa-file-excel-o"></i>&nbsp;导出excel</button>
					</div>
					<!--					<br/><span style="color: red;">提示：特殊订单如果司机未回款，实回款填0.001。</span>-->
                </form>
			
          </div>
                        
          <div id="ajax_return" class="g_list"> 
                    <div class="table-responsive">
                        <table class="table table-bordered table-hover">
                            <thead>
                            <tr>
								<th class="sorting text-center">订单号</th>
								<th class="sorting text-center">商户名</th>
                                <th class="sorting text-center">客户名</th>
								<th class="sorting text-center">订单价</th>
								<th class="sorting text-center">客户应收</th>
<!--								<th class="sorting text-center">现金</th>-->
<!--								<th class="sorting text-center">扫码支付</th>-->
								<th class="sorting text-center">包装件数</th>
								<th class="sorting text-center">未验收标签</th>
								<th class="sorting text-center">最后一次入库时间</th>

								<th class="sorting text-center">状态/标注</th>

                            </tr>
                            </thead>
							<tbody>
								<tr style="font-size: 16px;color: red; display: none">
									<td colspan="5" align="right">合计：</td>
									<td align="center">￥{$heji_price}</td>
									<td align="center"></td>
									<td align="center"></td>
									<td align="center"></td>
									<td align="center"></td>
									<td colspan="4"></td>
								</tr>
							</tbody>
                            <tbody>

                            <volist name="list" id="v">
	
								<volist name="v.order_list" id="vs">
                               <tr>

									<td class="text-center">
										<a href="javascript:" class="copy" id="chakan" rel="{$vs.order_id}" rev="{$vs.store_id}">{$vs.order_sn}</a>
										<if condition="$vs['pda_qdzt'] eq 1">
											<span  style="font-weight: bold; color: #f00">(平台标记没货)</span>
											<elseif condition="$vs['order_status'] eq 1  && $vs['jian_count'] gt 0 && $vs['ruku'] != $vs['jian_count']" />
											<span  style="font-weight: bold;color: #f00" >(入库件数不齐)</span>
										</if>
									</td>
                                    <td class="text-center">
                                            {$store_list[$vs[store_id]]}
                                    </td>
                                    <td class="text-center">
                                             （{$v.biaoshi_xian}）{$vs.company}<span id="yc">{$vs.user_id}</span>
                                    </td>
									<td class="text-center"><span style="color:#f39c12;">{$vs.order_amount}<span id="yc">{$vs.user_id}</span></span></td>
                                    <td class="text-center"><span id="yc">{$v.xiaoji}</span></td>
									<td class="text-center"><b>总部标签数：{$vs.jian_count} 件 -> {$vs.ruku_count}件 -> {$vs.chuku_count}件</b></td>
								   <td class="text-center">
								       <span onmouseover="layer.tips('关键词:{$vs.order_jian_msg}',this,{tips: [1, '#000']});" onmouseout="layer.closeAll();">{$vs.order_jian_msg|getSubstr=0,33}</span>
								   
								   </td>
								   <td class="text-center">{$vs.ruku_last_time|date="Y-m-d H:i",###}</td>
								   <td class="text-center" id="hui_{$v.order_id}">
										<if condition="$vs['tag_price'] eq '0'">
									    &nbsp;<i class="glyphicon glyphicon-flag" id="biaozhu" rel="0" title="标注未回款单据">未回款</i>
										<else/>
										&nbsp;<i class="glyphicon glyphicon-flag" id="biaozhu" rel="1" title="恢复未回款单据" style="color:red;">未回款</i>
										</if>
									</td>

                                </tr>
								</volist>
                            </volist>
                            </tbody>
                        </table>
                    </div>

                <div class="row">

                    <div class="col-sm-6 text-right">{$show}</div>
                </div>
          </div>
        </div>
      </div>
    </div>
    <!-- /.row --> 
  </section>
  <!-- /.content --> 
</div>
<!-- /.content-wrapper --> 
 <script>
	$(document).ready(function() {

		$('#add_time').daterangepicker({
			format:"YYYY-MM-DD HH:mm",
			singleDatePicker: false,
			showDropdowns: true,
			minDate:'2021-01-01 00:00',
			maxDate:'2030-01-01 00:00',
			startDate:'{:date("Y-m-d")} 00:00',
			showWeekNumbers: true,
			timePicker: true,
			timePickerIncrement: 1,
			timePicker12Hour: false,
			ranges: {
				'今天': [moment(), moment()],
				'昨天': [moment().subtract('days', 1), moment().subtract('days', 1)],
				'最近7天': [moment().subtract('days', 6), moment()],
				'最近30天': [moment().subtract('days', 29), moment()],
				'上一个月': [moment().subtract('month', 1).startOf('month'), moment().subtract('month', 1).endOf('month')]
			},
			opens: 'left',
			buttonClasses: ['btn btn-default'],
			applyClass: 'btn-small btn-primary',
			cancelClass: 'btn-small',
			locale : {
				applyLabel : '确定',
				cancelLabel : '取消',
				fromLabel : '起始时间',
				toLabel : '结束时间',
				customRangeLabel : '自定义',
				daysOfWeek : [ '日', '一', '二', '三', '四', '五', '六' ],
				monthNames : [ '一月', '二月', '三月', '四月', '五月', '六月','七月', '八月', '九月', '十月', '十一月', '十二月' ],
				firstDay : 1
			}
		});

		$("#daochu").click(function(){
			layer.load();
			var order_sn=$("#order_sn").val();
			var kehu=$("#kehu").val();
			var shanghu=$("#shanghu").val();
			var tag=$("#tag").val();
			var unusual_type=$("#unusual_type").val();
			var b1=$("#b1").val();
			var b2=$("#b2").val();
			var b3=$("#b3").val();
			var fast_flag=$("#fast_flag").val();
			var add_time=$("#add_time").val();

			location.href="/index.php/Admin/Finance/export_unusual?order_sn="+order_sn+"&kehu="+kehu+"&shanghu="+shanghu+"&tag="+tag+"&unusual_type="+unusual_type+"&b1="+b1+"&b2="+b2+"&b3="+b3+"&fast_flag="+fast_flag+"&timegap="+add_time;
			layer.closeAll('loading');
		})


		$('.copy').click(function (){
			let inputElement = document.createElement('input');
			var content = $(this).html()
			inputElement.type = 'text';
			inputElement.value = content;
			document.body.appendChild(inputElement);
			// 选择增加的input元素
			inputElement.select();
			if (document.execCommand('Copy', 'false', null)) {
				// 如果复制成功
				layer.msg('复制成功');
			}
			// 复制成功之后删除增加的这个input元素
			document.body.removeChild(inputElement);
		})
});






</script>
</body>
</html>